
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>理解Vue.Mixin，利用Vue.Mixin正确的偷懒 · 记录技术文档内容</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="zhengyuliang">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-sectionx/sectionx.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../javaScript/5个技巧让你更好的编写 JavaScript(ES6" />
    
    
    <link rel="prev" href="父组件监听到子组件的生命周期.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">CSS</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../CSS/18种CSS命名和书写规范.html">
            
                <a href="../CSS/18种CSS命名和书写规范.html">
            
                    
                    18种CSS命名和书写规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../CSS/灵活运用CSS开发技巧.html">
            
                <a href="../CSS/灵活运用CSS开发技巧.html">
            
                    
                    灵活运用CSS开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../CSS/自适应 flex grid.html">
            
                <a href="../CSS/自适应 flex grid.html">
            
                    
                    自适应 Flex Grid
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">HTML</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../HTML/浏览器里的本地数据库：IndexedDB.html">
            
                <a href="../HTML/浏览器里的本地数据库：IndexedDB.html">
            
                    
                    浏览器里的本地数据库：IndexedDB
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Vue</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="7个有用的Vue开发技巧.html">
            
                <a href="7个有用的Vue开发技巧.html">
            
                    
                    7个有用的Vue开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="Vue this.$router.push、replace、go的区别.html">
            
                <a href="Vue this.$router.push、replace、go的区别.html">
            
                    
                    Vue This.$Router.Push、Replace、Go的区别
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="Vue 的父组件和子组件生命周期钩子函数执行顺序？.html">
            
                <a href="Vue 的父组件和子组件生命周期钩子函数执行顺序？.html">
            
                    
                    Vue 的父组件和子组件生命周期钩子函数执行顺序？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="Vue.set和this.$set应用的场景.html">
            
                <a href="Vue.set和this.$set应用的场景.html">
            
                    
                    Vue.Set和This.$Set应用的场景
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="vue高级技巧.html">
            
                <a href="vue高级技巧.html">
            
                    
                    Vue高级技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="从 0 开始手把手带你搭建一套规范的 Vue3.x 项目工程环境.html">
            
                <a href="从 0 开始手把手带你搭建一套规范的 Vue3.x 项目工程环境.html">
            
                    
                    从 0 开始手把手带你搭建一套规范的 Vue3.X 项目工程环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="浅析 vue-router 源码和动态路由权限分配.html">
            
                <a href="浅析 vue-router 源码和动态路由权限分配.html">
            
                    
                    浅析 Vue Router 源码和动态路由权限分配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="父组件监听到子组件的生命周期.html">
            
                <a href="父组件监听到子组件的生命周期.html">
            
                    
                    父组件监听到子组件的生命周期
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="3.9" data-path="理解Vue.mixin，利用Vue.mixin正确的偷懒.html">
            
                <a href="理解Vue.mixin，利用Vue.mixin正确的偷懒.html">
            
                    
                    理解Vue.Mixin，利用Vue.Mixin正确的偷懒
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">JavaScript</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../javaScript/5个技巧让你更好的编写 JavaScript(ES6">
            
                <span>
            
                    
                    5个技巧让你更好的编写 JavaScript(ES6) 中条件语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../javaScript/5种常见函数的写法和调用方式.html">
            
                <a href="../javaScript/5种常见函数的写法和调用方式.html">
            
                    
                    5种常见函数的写法和调用方式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../javaScript/7道javascript题，让你理解基本的javascript.html">
            
                <a href="../javaScript/7道javascript题，让你理解基本的javascript.html">
            
                    
                    7道Javascript题，让你理解基本的Javascript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="../javaScript/Array.from(">
            
                <span>
            
                    
                    Array.From() 五个超好用的用途
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="../javaScript/ES6汇总资料.html">
            
                <a href="../javaScript/ES6汇总资料.html">
            
                    
                    ES6汇总资料
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="../javaScript/JS开发必须知道的41个技巧.html">
            
                <a href="../javaScript/JS开发必须知道的41个技巧.html">
            
                    
                    JS开发必须知道的41个技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="../javaScript/JavaScript之防抖Debounce和节流Throttle.html">
            
                <a href="../javaScript/JavaScript之防抖Debounce和节流Throttle.html">
            
                    
                    JavaScript之防抖Debounce和节流Throttle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="../javaScript/JavaScript数组求并集，交集和差集.html">
            
                <a href="../javaScript/JavaScript数组求并集，交集和差集.html">
            
                    
                    JavaScript数组求并集，交集和差集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.9" data-path="../javaScript/JavaScript的优雅写法.html">
            
                <a href="../javaScript/JavaScript的优雅写法.html">
            
                    
                    JavaScript的优雅写法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.10" data-path="../javaScript/axios知识点.html">
            
                <a href="../javaScript/axios知识点.html">
            
                    
                    Axios知识点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.11" data-path="../javaScript/javascript核心知识.html">
            
                <a href="../javaScript/javascript核心知识.html">
            
                    
                    Javascript核心知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.12" data-path="../javaScript/this、apply、call、bind.html">
            
                <a href="../javaScript/this、apply、call、bind.html">
            
                    
                    This、Apply、Call、Bind
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.13" data-path="../javaScript/前端js常用的60余种工具方法.html">
            
                <a href="../javaScript/前端js常用的60余种工具方法.html">
            
                    
                    前端Js常用的60余种工具方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.14" data-path="../javaScript/前端异常的捕获与处理.html">
            
                <a href="../javaScript/前端异常的捕获与处理.html">
            
                    
                    前端异常的捕获与处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.15" data-path="../javaScript/在 JavaScript 中交换值的 10 种方法.html">
            
                <a href="../javaScript/在 JavaScript 中交换值的 10 种方法.html">
            
                    
                    在 JavaScript 中交换值的 10 种方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.16" data-path="../javaScript/常用的前端JavaScript方法封装.html">
            
                <a href="../javaScript/常用的前端JavaScript方法封装.html">
            
                    
                    常用的前端JavaScript方法封装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.17" data-path="../javaScript/异步神器Async-await介绍与填坑.html">
            
                <a href="../javaScript/异步神器Async-await介绍与填坑.html">
            
                    
                    异步神器Async Await介绍与填坑
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.18" data-path="../javaScript/灵活运用JS开发技巧.html">
            
                <a href="../javaScript/灵活运用JS开发技巧.html">
            
                    
                    灵活运用JS开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.19" data-path="../javaScript/编写高质量可维护的代码：一目了然的注释.html">
            
                <a href="../javaScript/编写高质量可维护的代码：一目了然的注释.html">
            
                    
                    编写高质量可维护的代码：一目了然的注释
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.20" data-path="../javaScript/编写高质量可维护的代码：优化逻辑判断.html">
            
                <a href="../javaScript/编写高质量可维护的代码：优化逻辑判断.html">
            
                    
                    编写高质量可维护的代码：优化逻辑判断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.21" data-path="../javaScript/编写高质量可维护的代码：优雅命名.html">
            
                <a href="../javaScript/编写高质量可维护的代码：优雅命名.html">
            
                    
                    编写高质量可维护的代码：优雅命名
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.22" data-path="../javaScript/编写高质量可维护的代码：数据建模.html">
            
                <a href="../javaScript/编写高质量可维护的代码：数据建模.html">
            
                    
                    编写高质量可维护的代码：数据建模
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Life Exp</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../life_exp/告别平庸的15个小方法.html">
            
                <a href="../life_exp/告别平庸的15个小方法.html">
            
                    
                    告别平庸的15个小方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../life_exp/日志记录.html">
            
                <a href="../life_exp/日志记录.html">
            
                    
                    日志记录
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../life_exp/程序员的发展方向.html">
            
                <a href="../life_exp/程序员的发展方向.html">
            
                    
                    程序员的发展方向
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="../message/">
            
                <a href="../message/">
            
                    
                    Message
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Technology</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../technology/WebSocket.html">
            
                <a href="../technology/WebSocket.html">
            
                    
                    WebSocket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="../technology/npm常用命令大全.html">
            
                <a href="../technology/npm常用命令大全.html">
            
                    
                    Npm常用命令大全
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="../technology/智能照明项目说明.html">
            
                <a href="../technology/智能照明项目说明.html">
            
                    
                    智能照明项目说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="../technology/规范化git的提交信息.html">
            
                <a href="../technology/规范化git的提交信息.html">
            
                    
                    规范化Git的提交信息
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Tutorial</li>
        
        
    
        <li class="chapter " data-level="7.1" data-path="../tutorial/Esmap地图详解.html">
            
                <a href="../tutorial/Esmap地图详解.html">
            
                    
                    Esmap地图详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="../tutorial/npm镜像切换.html">
            
                <a href="../tutorial/npm镜像切换.html">
            
                    
                    Npm镜像切换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="../tutorial/发布npm的教程.html">
            
                <a href="../tutorial/发布npm的教程.html">
            
                    
                    发布Npm的教程
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >理解Vue.Mixin，利用Vue.Mixin正确的偷懒</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <html><head></head><body><div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><li><span class="title-icon "></span><a href="#&#x7406;&#x89E3;vuemixin&#xFF0C;&#x5229;&#x7528;vuemixin&#x6B63;&#x786E;&#x7684;&#x5077;&#x61D2;"><b>1.1. </b>&#x7406;&#x89E3;Vue.mixin&#xFF0C;&#x5229;&#x7528;Vue.mixin&#x6B63;&#x786E;&#x7684;&#x5077;&#x61D2;</a></li><ul><li><span class="title-icon "></span><a href="#&#x5C40;&#x90E8;&#x6DF7;&#x5165;"><b>1.1.1. </b>&#x5C40;&#x90E8;&#x6DF7;&#x5165;</a></li></ul></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h2 id="&#x7406;&#x89E3;vuemixin&#xFF0C;&#x5229;&#x7528;vuemixin&#x6B63;&#x786E;&#x7684;&#x5077;&#x61D2;"><a name="&#x7406;&#x89E3;vuemixin&#xFF0C;&#x5229;&#x7528;vuemixin&#x6B63;&#x786E;&#x7684;&#x5077;&#x61D2;" class="anchor-navigation-ex-anchor" href="#&#x7406;&#x89E3;vuemixin&#xFF0C;&#x5229;&#x7528;vuemixin&#x6B63;&#x786E;&#x7684;&#x5077;&#x61D2;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. &#x7406;&#x89E3;Vue.mixin&#xFF0C;&#x5229;&#x7528;Vue.mixin&#x6B63;&#x786E;&#x7684;&#x5077;&#x61D2;</h2>
<blockquote>
<p>&#x521A;&#x8FDB;&#x5165;vue&#x9879;&#x76EE;&#xFF0C;&#x6709;&#x90E8;&#x5206;&#x7EC6;&#x8282;&#x529F;&#x80FD;&#x4E0D;&#x6E05;&#x695A;&#x3002;&#x6BB5;&#x671F;&#x505A;&#x4E86;&#x4E00;&#x4E2A;vue&#x9879;&#x76EE;&#xFF0C;&#x770B;&#x5230;&#x4F7F;&#x7528;vue.mixin&#x529F;&#x80FD;&#xFF0C;&#x5C31;&#x60F3;&#x53BB;&#x4E86;&#x89E3;&#x900F;&#x600E;&#x4E48;&#x5E94;&#x7528;&#x53CA;&#x4F7F;&#x7528;&#x539F;&#x7406;&#xFF0C;&#x6545;&#x6709;&#x4E86;&#x4E0B;&#x6587;</p>
</blockquote>
<p> <strong>&#x5173;&#x4E8E;Vue.mixin &#xFF0C;&#x5B98;&#x65B9;&#x89E3;&#x91CA;&#x5982;&#x4E0B;</strong></p>
<p> &#x6DF7;&#x5165; (mixin) &#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x79CD;&#x975E;&#x5E38;&#x7075;&#x6D3B;&#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x6765;&#x5206;&#x53D1; Vue &#x7EC4;&#x4EF6;&#x4E2D;&#x7684;&#x53EF;&#x590D;&#x7528;&#x529F;&#x80FD;&#x3002;&#x4E00;&#x4E2A;&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x53EF;&#x4EE5;&#x5305;&#x542B;&#x4EFB;&#x610F;&#x7EC4;&#x4EF6;&#x9009;&#x9879;&#x3002;&#x5F53;&#x7EC4;&#x4EF6;&#x4F7F;&#x7528;&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x65F6;&#xFF0C;&#x6240;&#x6709;&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x7684;&#x9009;&#x9879;&#x5C06;&#x88AB;&#x201C;&#x6DF7;&#x5408;&#x201D;&#x8FDB;&#x5165;&#x8BE5;&#x7EC4;&#x4EF6;&#x672C;&#x8EAB;&#x7684;&#x9009;&#x9879;&#x3002; <em>&#xFF08;&#x4E0D;&#x7406;&#x89E3;&#xFF0C;&#x6240;&#x4EE5;&#x770B;&#x53EA;&#x6709;&#x770B;&#x4F8B;&#x5B50;&#x54AF;&#xFF09;</em></p>
<p> Vue.mixin&#x4E3A;&#x6211;&#x4EEC;&#x63D0;&#x4F9B;&#x4E86;&#x4E24;&#x79CD;&#x6DF7;&#x5165;&#x65B9;&#x5F0F;&#xFF1A;<strong>&#x5C40;&#x90E8;&#x6DF7;&#x5165;</strong>&#x548C;<strong>&#x5168;&#x5C40;&#x6DF7;&#x5165;</strong>&#xFF1B; <em>&#xFF08;&#x597D;&#x50CF;&#x6709;&#x5173;vue&#x90FD;&#x57FA;&#x672C;&#x4E0A;&#x90FD;&#x6709;&#x5C40;&#x90E8;&#x4E0E;&#x5408;&#x5C40;&#x52A0;&#x8F7D;&#x4E00;&#x8BF4;&#xFF0C;~&#xFF09;</em></p>
<h3 id="&#x5C40;&#x90E8;&#x6DF7;&#x5165;"><a name="&#x5C40;&#x90E8;&#x6DF7;&#x5165;" class="anchor-navigation-ex-anchor" href="#&#x5C40;&#x90E8;&#x6DF7;&#x5165;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.1. &#x5C40;&#x90E8;&#x6DF7;&#x5165;</h3>
<p> &#x987E;&#x540D;&#x601D;&#x4E49;&#x5C31;&#x662F;&#x90E8;&#x5206;&#x6DF7;&#x5165;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x53EA;&#x6709;&#x5F15;&#x5165;&#x4E86;mixin&#x7684;&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x624D;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#xFF0C;&#x5E76;&#x4E14;&#x53EA;&#x6709;&#x5728;&#x5F15;&#x5165;&#x4E86;mixin&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x7684;&#x7EC4;&#x4EF6;&#x4E2D;&#x624D;&#x751F;&#x6548;&#xFF1B; </p>
<p> &#x9996;&#x5148;&#x81EA;&#x5DF1;&#x642D;&#x5EFA;Vue&#x7684;&#x5F00;&#x53D1;&#x73AF;&#x5883;&#xFF0C;&#x7136;&#x540E;&#x6211;&#x4EEC;&#x5728;src&#x76EE;&#x5F55;&#x4E2D;&#x65B0;&#x5EFA;&#x4E24;&#x4E2A;vue&#x6587;&#x4EF6;&#xFF0C;&#x5206;&#x522B;&#x662F;page1.vue&#x548C;page2.vue&#xFF1B; </p>
<pre><code class="lang-vue">//page1.vue
&lt;template&gt;
    &lt;div&gt;page1&#x7684;&#x503C;&#x662F;:&lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
export default {
  data () {
    return {

    }
  },
}
&lt;/script&gt;

&lt;style scoped&gt;

&lt;/style&gt;
</code></pre>
<pre><code class="lang-vue">//page2.vue
&lt;template&gt;
    &lt;div&gt;page2&#x7684;&#x503C;&#x662F;:&lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
export default {
  data () {
    return {

    }
  }
}
&lt;/script&gt;

&lt;style scoped&gt;

&lt;/style&gt;
</code></pre>
<pre><code class="lang-vue">//app.vue
&lt;template&gt;
  &lt;div id=&quot;app&quot;&gt;
    &lt;button @click=&quot;method1&quot;&gt;page1&lt;/button&gt;
    &lt;button @click=&quot;method2&quot;&gt;page2&lt;/button&gt;

    &lt;router-view&gt;&lt;/router-view&gt;
  &lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
export default {
  name: &apos;App&apos;,
  methods:{
    method1(){
      this.$router.push(&apos;/page1&apos;);
    },
    method2(){
      this.$router.push(&apos;/page2&apos;);
    }
  }
}
&lt;/script&gt;

&lt;style&gt;
#app {
  font-family: &apos;Avenir&apos;, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
&lt;/style&gt;
</code></pre>
<p> &#x5728;src&#x76EE;&#x5F55;&#x4E0B;&#x521B;&#x5EFA;router.js&#x6587;&#x4EF6;&#xFF0C;&#x914D;&#x7F6E;&#x8DEF;&#x7531;&#x5B9E;&#x73B0;&#x8DF3;&#x8F6C; </p>
<pre><code class="lang-javascript"><span class="hljs-comment">// router.js</span>
<span class="hljs-keyword">import</span> Vue <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;vue&quot;</span>;
<span class="hljs-keyword">import</span> VueRouter <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;vue-router&quot;</span>;
Vue.use(VueRouter);

<span class="hljs-keyword">import</span> page1 <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;./page1&quot;</span>;
<span class="hljs-keyword">import</span> page2 <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;./page2&quot;</span>;

<span class="hljs-keyword">const</span> routes=[
    {<span class="hljs-attr">path</span>:<span class="hljs-string">&quot;/page1&quot;</span>,<span class="hljs-attr">component</span>:page1},
    {<span class="hljs-attr">path</span>:<span class="hljs-string">&quot;/page2&quot;</span>,<span class="hljs-attr">component</span>:page2}
]


<span class="hljs-keyword">const</span> router=<span class="hljs-keyword">new</span> VueRouter({
    routes
})


<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> router
</code></pre>
<p> &#x6700;&#x540E;&#x5C06;&#x8DEF;&#x7531;&#x5F15;&#x5165;main.js&#x4E2D;&#xFF1A; </p>
<pre><code class="lang-javascript"><span class="hljs-comment">// main.js</span>
<span class="hljs-comment">// The Vue build version to load with the `import` command</span>
<span class="hljs-comment">// (runtime-only or standalone) has been set in webpack.base.conf with an alias.</span>
<span class="hljs-keyword">import</span> Vue <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;vue&apos;</span>
<span class="hljs-keyword">import</span> App <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;./App&apos;</span>
<span class="hljs-keyword">import</span> router <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;./router.js&apos;</span>

Vue.config.productionTip = <span class="hljs-literal">false</span>


<span class="hljs-comment">/* eslint-disable no-new */</span>
<span class="hljs-keyword">new</span> Vue({
  <span class="hljs-attr">el</span>: <span class="hljs-string">&apos;#app&apos;</span>,
  router,
  <span class="hljs-attr">components</span>: { App },
  <span class="hljs-attr">template</span>: <span class="hljs-string">&apos;&lt;App/&gt;&apos;</span>
})
</code></pre>
<p> &#x5B8C;&#x6210;&#x4E0A;&#x8FF0;&#x51C6;&#x5907;&#x5DE5;&#x4F5C;&#x4E4B;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x73B0;&#x5728;&#x7684;&#x9875;&#x9762;&#x6548;&#x679C;&#x5982;&#x4E0B;&#xFF1A; </p>
<p><img src="https://raw.githubusercontent.com/zhengyuliang/Blog-Back-Up/master/images/vue/vue_mixin.png" alt="vue"></p>
<p> &#x6CA1;&#x6709;&#x62A5;&#x9519;&#xFF0C;&#x6211;&#x4EEC;&#x5F00;&#x59CB;&#x6B63;&#x5F0F;&#x8FDB;&#x5165;&#x5B66;&#x4E60;Vue.mixin&#xFF1A; </p>
<p><em>&#x6CE8;&#xFF1A;&#x7EC8;&#x4E8E;&#x5F00;&#x59CB;&#x5B66;&#x4E60;&#x4E86;&#xFF0C;&#x96BE;&#x5F97;&#x5440;</em></p>
<p> &#x9996;&#x5148;&#x6211;&#x4EEC;&#x5728;src&#x76EE;&#x5F55;&#x4E0B;&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;&#x540D;&#x4E3A;mixin&#x7684;&#x6587;&#x4EF6;&#x5939;&#x5E76;&#x5728;mixin&#x6587;&#x4EF6;&#x4E2D;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;mixin.js&#x6587;&#x4EF6;&#xFF1A; </p>
<pre><code class="lang-javascript"><span class="hljs-comment">//&#x629B;&#x51FA;&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#xFF0C;&#x65B9;&#x4FBF;&#x5916;&#x90E8;&#x8BBF;&#x95EE; mixin.js</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> mixin={
    data(){
        <span class="hljs-keyword">return</span> {
            <span class="hljs-attr">number</span>:<span class="hljs-number">1</span>
        }
    }
}
</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x6211;&#x4EEC;&#x5728;&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x4E2D;&#x521B;&#x5EFA;&#x4E86;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#xFF0C;&#x662F;&#x7684;&#xFF0C;&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x8DDF;Vue&#x5B9E;&#x4F8B;&#x7684;&#x683C;&#x5F0F;&#x662F;&#x4E00;&#x6837;&#x7684;&#xFF1B;</p>
<p>&#x7136;&#x540E;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5C06;mixin.js&#x5F15;&#x5165;&#x5230;&#x6211;&#x4EEC;&#x7684;page1.vue&#x548C;page2.vue&#x4E2D;</p>
<pre><code class="lang-vue">// page1.vue
&lt;template&gt;
    //&#x8FD9;&#x91CC;&#x8BFB;&#x7684;&#x503C;&#x5176;&#x5B9E;&#x662F;mixin&#x7684;&#x503C;&#xFF0C;&#x56E0;&#x4E3A;&#x8FD9;&#x4E2A;&#x65F6;&#x5019;mixin&#x5DF2;&#x7ECF;&#x6DF7;&#x5165;&#x5230;vue&#x5B9E;&#x4F8B;&#x4E2D;&#x4E86;
    &lt;div&gt;page1&#x7684;&#x503C;&#x662F;:&lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
//&#x5F15;&#x5165;mixin.js
import {mixin} from &quot;./mixin/mixin&quot;
export default {
//&#x8FD9;&#x91CC;&#x6CE8;&#x610F;&#xFF1A;&#x5C5E;&#x6027;&#x540D;&#x4E3A;mixins&#xFF0C;&#x503C;&#x4E3A;&#x6570;&#x7EC4;&#x7C7B;&#x578B;
  mixins:[mixin],
  data () {
    return {

    }
  },
}
&lt;/script&gt;

&lt;style scoped&gt;

&lt;/style&gt;
</code></pre>
<pre><code class="lang-vue">// page2.vue
&lt;template&gt;
    &lt;div&gt;page2&#x7684;&#x503C;&#x662F;:&lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
import {mixin} from &quot;./mixin/mixin&quot;
export default {
  mixins:[mixin],
  data () {
    return {

    }
  }
}
&lt;/script&gt;

&lt;style scoped&gt;

&lt;/style&gt;
</code></pre>
<p> &#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x7684;&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x5DF2;&#x7ECF;&#x6210;&#x529F;&#x6DF7;&#x5165;&#x5230;Vue&#x5B9E;&#x4F8B;&#x4E2D;&#xFF0C;&#x4F60;&#x4EEC;&#x53EF;&#x4EE5;&#x70B9;&#x51FB;&#x770B;&#x770B;&#x6548;&#x679C;&#xFF0C;&#x662F;&#x53EF;&#x4EE5;&#x6B63;&#x5E38;&#x8FD0;&#x884C;&#x5E76;&#x4E14;&#x80FD;&#x8BFB;&#x53D6;&#x5230;&#x503C;&#x7684;&#xFF1B; </p>
<p> &#x73B0;&#x5728;&#x6211;&#x4EEC;&#x6765;&#x4FEE;&#x6539;page1.vue&#x7684;&#x4EE3;&#x7801;&#xFF1A; </p>
<pre><code class="lang-vue">//page1.vue
&lt;template&gt;
    &lt;div&gt;page2&#x7684;&#x503C;&#x662F;:&lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
import {mixin} from &quot;./mixin/mixin&quot;
export default {
  mixins:[mixin],
  data () {
    return {

    }
  }
}
&lt;/script&gt;

&lt;style scoped&gt;

&lt;/style&gt;
</code></pre>
<p>page2&#x4E0D;&#x53D8;&#xFF0C;&#x518D;&#x8FD0;&#x884C;&#x53EF;&#x4EE5;&#x53D1;&#x73B0;&#xFF0C;&#x6211;&#x4EEC;&#x7684;page1.vue&#x4E2D;&#x7684;&#x503C;&#x662F;&#x6267;&#x884C;&#x4E86;mounted&#xFF0C;&#x6240;&#x4EE5;&#x4EA7;&#x751F;&#x4E86;&#x81EA;&#x589E;</p>
<p>&#x7531;&#x6B64;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x77E5;&#x9053;mixin&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x7684;&#x53D8;&#x91CF;&#x662F;&#x4E0D;&#x4F1A;&#x5171;&#x4EAB;&#x7684;&#xFF1B;&#x4E5F;&#x5C31;&#x662F;&#x4F60;page1&#x53D1;&#x751F;&#x4E86;&#x53D8;&#x5316;&#xFF0C;&#x5E76;&#x4E0D;&#x4F1A;&#x901A;&#x77E5;mixin&#x8FDB;&#x884C;&#x5B9E;&#x65F6;&#x5237;&#x65B0;&#x6570;&#x636E;&#xFF0C;&#x53D1;&#x751F;&#x7684;&#x53D8;&#x5316;&#x53EA;&#x4F1A;&#x5728;page1.vue&#x4E2D;&#x751F;&#x6548;&#xFF0C;&#x4E0D;&#x5F71;&#x54CD;&#x5176;&#x4ED6;&#x7EC4;&#x4EF6;&#xFF1B;</p>
<p> &#x73B0;&#x5728;&#x6211;&#x4EEC;&#x4FEE;&#x6539;mixin.js&#x548C;page1.vue&#x4E2D;&#x7684;&#x4EE3;&#x7801;&#xFF1A; </p>
<pre><code class="lang-javascript"><span class="hljs-comment">// mixin.js</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> mixin={
    data(){
        <span class="hljs-keyword">return</span> {
            <span class="hljs-attr">number</span>:<span class="hljs-number">1</span>
        }
    },
    created(){
            <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;mixin&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&quot;</span>)
    }
}
</code></pre>
<pre><code class="lang-vue">// page1.vue
&lt;template&gt;
    &lt;div&gt;page1&#x7684;&#x503C;&#x662F;:&lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
import {mixin} from &quot;./mixin/mixin&quot;
export default {
  mixins:[mixin],
  data () {
    return {

    }
  },
  created(){
          console.log(&quot;&#x8FD9;&#x91CC;&#x662F;page1&quot;);
  }
}
&lt;/script&gt;

&lt;style scoped&gt;

&lt;/style&gt;
</code></pre>
<p> &#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x518D;&#x8FD0;&#x884C;&#x53EF;&#x4EE5;&#x53D1;&#x73B0;&#x63A7;&#x5236;&#x53F0;&#x8F93;&#x51FA;&#x662F;&#x8FD9;&#x4E2A;&#x6837;&#x5B50;&#x7684;&#xFF1A; </p>
<p><img src="https://raw.githubusercontent.com/zhengyuliang/Blog-Back-Up/master/images/vue/vue_mixin_01.png" alt="vue"></p>
<p>&#x662F;&#x7684;&#xFF0C;mixin&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x4E2D;&#x58F0;&#x660E;&#x4E86;&#xFF1A;&#x5982;&#x679C;&#x662F;&#x540C;&#x540D;&#x94A9;&#x5B50;&#x51FD;&#x6570;&#x5C06;&#x5408;&#x5E76;&#x4E3A;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;&#xFF0C;&#x56E0;&#x6B64;&#x90FD;&#x88AB;&#x8C03;&#x7528;&#xFF0C;&#x4F46;&#x662F;&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x7684;&#x94A9;&#x5B50;&#x5C06;&#x5728;&#x81EA;&#x8EAB;&#x5B9E;&#x4F8B;&#x94A9;&#x5B50;&#x4E4B;&#x524D;&#x89E6;&#x53D1;&#xFF1B;</p>
<p>&#x503C;&#x4E3A;&#x5BF9;&#x8C61;&#x7684;&#x9009;&#x9879;&#xFF0C;&#x4F8B;&#x5982;methods,components&#x7B49;&#x5982;&#x679C;&#x53D8;&#x91CF;&#x540D;&#x548C;mixin&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x7684;&#x53D8;&#x91CF;&#x540D;&#x53D1;&#x751F;&#x51B2;&#x7A81;&#xFF0C;&#x5C06;&#x4F1A;&#x4EE5;&#x7EC4;&#x4EF6;&#x4F18;&#x5148;&#x5E76;&#x8FDB;&#x884C;&#x9012;&#x5F52;&#x5408;&#x5E76;&#xFF0C;&#x76F8;&#x5F53;&#x4E8E;&#x7EC4;&#x4EF6;&#x6570;&#x636E;&#x76F4;&#x63A5;&#x8986;&#x76D6;&#x4E86;mixin&#x4E2D;&#x7684;&#x540C;&#x540D;&#x6570;&#x636E;&#xFF1B;</p>
<p> &#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4FEE;&#x6539;&#x4EE3;&#x7801;mixin.js&#x548C;page1.vue </p>
<pre><code class="lang-javascript"><span class="hljs-comment">// mixin.js</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> mixin={
    data(){
        <span class="hljs-keyword">return</span> {
            <span class="hljs-attr">number</span>:<span class="hljs-number">1</span>
        }
    },
    <span class="hljs-attr">methods</span>:{
        demo1(){
            <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;mixin&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&quot;</span>)
        }
    }
}
</code></pre>
<pre><code class="lang-vue">//page1.vue
&lt;template&gt;
    &lt;div&gt;page1&#x7684;&#x503C;&#x662F;:&lt;/div&gt;
&lt;/template&gt;

&lt;script&gt;
import {mixin} from &quot;./mixin/mixin&quot;
export default {
  mixins:[mixin],
  data () {
    return {
        number:10
    }
  },
  mounted(){
      this.demo1();
  },
  methods:{
      demo1(){
        console.log(&quot;&#x8FD9;&#x91CC;&#x662F;page1&quot;);
      }   
  }
}
&lt;/script&gt;

&lt;style scoped&gt;

&lt;/style&gt;
</code></pre>
<p> &#x8FD0;&#x884C;&#x4EE3;&#x7801;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5F88;&#x6E05;&#x6670;&#x7684;&#x770B;&#x5230;&#x90FD;&#x662F;&#x6267;&#x884C;&#x6211;&#x4EEC;&#x7EC4;&#x4EF6;&#x5185;&#x7684;&#x503C;&#xFF1B; </p>
<p><img src="https://raw.githubusercontent.com/zhengyuliang/Blog-Back-Up/master/images/vue/vue_mixin_02.png" alt="vue"></p>
<p> &#x56E0;&#x4E3A;&#x5728;vue&#x4E2D;&#x6211;&#x4EEC;&#x5728;&#x5B9E;&#x4F8B;&#x4E2D;&#x58F0;&#x660E;&#x53D8;&#x91CF;&#x4E5F;&#x662F;&#x901A;&#x8FC7;&#x952E;&#x503C;&#x5BF9;&#x7684;&#x5F62;&#x5F0F;&#x6765;&#x58F0;&#x660E;&#x7684;&#xFF0C;&#x5176;&#x5B9E;&#x4E5F;&#x662F;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#xFF1B; </p>
<h4 id="&#x5168;&#x5C40;&#x6DF7;&#x5165;"><a name="&#x5168;&#x5C40;&#x6DF7;&#x5165;" class="anchor-navigation-ex-anchor" href="#&#x5168;&#x5C40;&#x6DF7;&#x5165;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5168;&#x5C40;&#x6DF7;&#x5165;</h4>
<p> &#x5168;&#x5C40;&#x6DF7;&#x5165;&#x6211;&#x4EEC;&#x53EA;&#x9700;&#x8981;&#x628A;mixin.js&#x5F15;&#x5165;&#x5230;main.js&#x4E2D;&#xFF0C;&#x7136;&#x540E;&#x5C06;mixin&#x653E;&#x5165;&#x5230;Vue.mixin()&#x65B9;&#x6CD5;&#x4E2D;&#x5373;&#x53EF;&#xFF1B; </p>
<pre><code class="lang-javascript"><span class="hljs-comment">// main.js</span>
<span class="hljs-comment">// The Vue build version to load with the `import` command</span>
<span class="hljs-comment">// (runtime-only or standalone) has been set in webpack.base.conf with an alias.</span>
<span class="hljs-keyword">import</span> Vue <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;vue&apos;</span>
<span class="hljs-keyword">import</span> App <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;./App&apos;</span>
<span class="hljs-keyword">import</span> router <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;./router.js&apos;</span>
<span class="hljs-keyword">import</span> mixin <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;./mixin/mixin.js&quot;</span>
Vue.config.productionTip = <span class="hljs-literal">false</span>
Vue.mixin(mixin)

<span class="hljs-comment">/* eslint-disable no-new */</span>
<span class="hljs-keyword">new</span> Vue({
  <span class="hljs-attr">el</span>: <span class="hljs-string">&apos;#app&apos;</span>,
  router,
  <span class="hljs-attr">components</span>: { App },
  <span class="hljs-attr">template</span>: <span class="hljs-string">&apos;&lt;App/&gt;&apos;</span>
})
</code></pre>
<p>&#x662F;&#x7684;&#xFF0C;&#x5168;&#x5C40;&#x6DF7;&#x5165;&#x66F4;&#x4E3A;&#x4FBF;&#x6377;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;&#x4E0D;&#x7528;&#x5728;&#x5B50;&#x7EC4;&#x4EF6;&#x58F0;&#x660E;&#xFF0C;&#x5168;&#x5C40;&#x6DF7;&#x5165;&#x5C06;&#x4F1A;&#x5F71;&#x54CD;&#x6BCF;&#x4E00;&#x4E2A;&#x7EC4;&#x4EF6;&#x7684;&#x5B9E;&#x4F8B;&#xFF0C;&#x4F7F;&#x7528;&#x7684;&#x65F6;&#x5019;&#x9700;&#x8981;&#x5C0F;&#x5FC3;&#x8C28;&#x614E;&#xFF1B;&#x8FD9;&#x6837;&#x5168;&#x5C40;&#x6DF7;&#x5165;&#x4E4B;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5728;&#x7EC4;&#x4EF6;&#x4E2D;&#x901A;&#x8FC7;this.&#x53D8;&#x91CF;/&#x65B9;&#x6CD5;&#x6765;&#x8C03;&#x7528;mixin&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x7684;&#x53D8;&#x91CF;/&#x65B9;&#x6CD5;&#xFF1B;</p>
<p><em>&#x5F88;&#x591A;&#x540C;&#x5B66;&#x53EF;&#x80FD;&#x770B;&#x5230;&#x8FD9;&#x91CC;&#x4F1A;&#x6709;&#x4E00;&#x4E9B;&#x7591;&#x95EE;&#xFF0C;&#x8FD9;&#x4E0D;&#x5C31;&#x8DDF;Vuex&#x5DEE;&#x4E0D;&#x591A;&#x561B;&#xFF0C;&#x5176;&#x5B9E;&#x4E0D;&#x662F;&#x7684;&#xFF1A;</em></p>
<h4 id="mixin&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x548C;vuex&#x7684;&#x533A;&#x522B;&#xFF1A;"><a name="mixin&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x548C;vuex&#x7684;&#x533A;&#x522B;&#xFF1A;" class="anchor-navigation-ex-anchor" href="#mixin&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x548C;vuex&#x7684;&#x533A;&#x522B;&#xFF1A;"><i class="fa fa-link" aria-hidden="true"></i></a>mixin&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x548C;Vuex&#x7684;&#x533A;&#x522B;&#xFF1A;</h4>
<p><strong>Vuex&#x662F;&#x72B6;&#x6001;&#x5171;&#x4EAB;&#x7BA1;&#x7406;&#xFF0C;&#x6240;&#x4EE5;Vuex&#x4E2D;&#x7684;&#x6240;&#x6709;&#x53D8;&#x91CF;&#x548C;&#x65B9;&#x6CD5;&#x90FD;&#x662F;&#x53EF;&#x4EE5;&#x8BFB;&#x53D6;&#x548C;&#x66F4;&#x6539;&#x5E76;&#x76F8;&#x4E92;&#x5F71;&#x54CD;&#x7684;&#xFF1B;</strong></p>
<p>mixin&#x53EF;&#x4EE5;&#x5B9A;&#x4E49;&#x516C;&#x7528;&#x7684;&#x53D8;&#x91CF;&#x6216;&#x65B9;&#x6CD5;&#xFF0C;&#x4F46;&#x662F;mixin&#x4E2D;&#x7684;&#x6570;&#x636E;&#x662F;&#x4E0D;&#x5171;&#x4EAB;&#x7684;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x6BCF;&#x4E2A;&#x7EC4;&#x4EF6;&#x4E2D;&#x7684;mixin&#x5B9E;&#x4F8B;&#x90FD;&#x662F;&#x4E0D;&#x4E00;&#x6837;&#x7684;&#xFF0C;&#x90FD;&#x662F;&#x5355;&#x72EC;&#x5B58;&#x5728;&#x7684;&#x4E2A;&#x4F53;&#xFF0C;&#x4E0D;&#x5B58;&#x5728;&#x76F8;&#x4E92;&#x5F71;&#x54CD;&#x7684;&#xFF1B;</p>
<p><strong>mixin&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x503C;&#x4E3A;&#x51FD;&#x6570;&#x7684;&#x540C;&#x540D;&#x51FD;&#x6570;&#x9009;&#x9879;&#x5C06;&#x4F1A;&#x8FDB;&#x884C;&#x9012;&#x5F52;&#x5408;&#x5E76;&#x4E3A;&#x6570;&#x7EC4;</strong>&#xFF0C;&#x4E24;&#x4E2A;&#x51FD;&#x6570;&#x90FD;&#x4F1A;&#x6267;&#x884C;&#xFF0C;&#x53EA;&#x4E0D;&#x8FC7;&#x5148;&#x6267;&#x884C;mixin&#x4E2D;&#x7684;&#x540C;&#x540D;&#x51FD;&#x6570;&#xFF1B;</p>
<p><strong>mixin&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x503C;&#x4E3A;&#x5BF9;&#x8C61;&#x7684;&#x540C;&#x540D;&#x5BF9;&#x8C61;&#x5C06;&#x4F1A;&#x8FDB;&#x884C;&#x66FF;&#x6362;</strong>&#xFF0C;&#x90FD;&#x4F18;&#x5148;&#x6267;&#x884C;&#x7EC4;&#x4EF6;&#x5185;&#x7684;&#x540C;&#x540D;&#x5BF9;&#x8C61;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x7EC4;&#x4EF6;&#x5185;&#x7684;&#x540C;&#x540D;&#x5BF9;&#x8C61;&#x5C06;mixin&#x6DF7;&#x5165;&#x5BF9;&#x8C61;&#x7684;&#x540C;&#x540D;&#x5BF9;&#x8C61;&#x8FDB;&#x884C;&#x8986;&#x76D6;&#xFF1B; </p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; zhengyuliang all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x7F16;&#x5199;&#x65F6;&#x95F4;&#xFF1A;
2019-11-15 14:50:50
</span></footer></body></html>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="父组件监听到子组件的生命周期.html" class="navigation navigation-prev " aria-label="Previous page: 父组件监听到子组件的生命周期">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../javaScript/5个技巧让你更好的编写 JavaScript(ES6" class="navigation navigation-next " aria-label="Next page: 5个技巧让你更好的编写 JavaScript(ES6) 中条件语句">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"理解Vue.Mixin，利用Vue.Mixin正确的偷懒","level":"3.9","depth":1,"next":{"title":"5个技巧让你更好的编写 JavaScript(ES6) 中条件语句","level":"4.1","depth":1,"path":"javaScript/5个技巧让你更好的编写 JavaScript(ES6","ref":"javaScript/5个技巧让你更好的编写 JavaScript(ES6","articles":[]},"previous":{"title":"父组件监听到子组件的生命周期","level":"3.8","depth":1,"path":"Vue/父组件监听到子组件的生命周期.md","ref":"Vue/父组件监听到子组件的生命周期.md","articles":[]},"dir":"ltr"},"config":{"plugins":["sectionx","splitter","tbfed-pagefooter","toggle-chapters","theme-comscore","-lunr","-search","search-plus","donate","anchor-navigation-ex","expandable-chapters","chapter-fold","expandable-chapters-small","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy zhengyuliang","modify_label":"该文件编写时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"pluginsConfig":{"anchor-navigation-ex":{"showLevel":false,"showGoTop":true,"isRewritePageTitle":true,"isShowTocTitleIcon":true,"tocLevel1Icon":"fa fa-hand-o-right","tocLevel2Icon":"fa fa-hand-o-right","tocLevel3Icon":"fa fa-hand-o-right"}},"livereload":{},"splitter":{},"donate":{"title":"","button":"赏","wechat":"https://gitee.com/htzyl/img_bed/raw/master/pay/weixin-min.jpg","alipay":"https://gitee.com/htzyl/img_bed/raw/master/pay/alipay-min.jpg","wechatText":"微信打赏","alipayText":"支付宝打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"sectionx":{"tag":"b"},"highlight":{},"anchor-navigation-ex":{"showLevel":true,"associatedWithSummary":true,"mode":"float","showGoTop":true,"printLog":false,"multipleH1":true,"float":{"floatIcon":"fa fa-navicon","showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""},"pageTop":{"showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""}},"theme-comscore":{},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"zhengyuliang","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"记录技术文档内容","language":"zh-hans","gitbook":">=3.0.0","description":"记录Gitbook的配置和一些插件的使用","theme-default":{"showLevel":true}},"file":{"path":"Vue/理解Vue.mixin，利用Vue.mixin正确的偷懒.md","mtime":"2019-11-15T06:50:50.976Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-01-06T09:44:01.178Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sectionx/sectionx.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

